﻿/***************************************************************
 * 口口
 * 摄像机移动（拖动、缩放）加锁的管理器，用来点击选中对象时暂停摄像机的拖动、缩放操作
 ***************************************************************/

using UnityEngine;

namespace WorldMap.CameraController
{
    public class CameraMoveLockMgr
    {
        private static int k_LockBit = 0;

        // C#端的Mask编号保留值7。即0到7为C#逻辑所用。其余位开放给Lua使用

        public static readonly int MaskIdBuildSelected = 0;
        public static readonly int MaskIdMarchSelected = 1;
        public static readonly int MaskIdPveSelected = 2;

        public static void LockCameraMove(int maskId)
        {
            WorldCameraManager.cameraController.SetCameraLockStatus(true);

            // 姚艺-暂时关闭mask判断
            // int m = 1 << maskId;
            //
            // if ((k_LockBit & m) == 0)
            // {
            //     k_LockBit |= m;
            //     CheckCameraState();
            // }
        }
        
        public static void UnLockCameraMove(int maskId)
        {
            WorldCameraManager.cameraController.SetCameraLockStatus(false);

            //
            // int m = 1 << maskId;
            // if ((k_LockBit & m) != 0)
            // {
            //     k_LockBit &= ~m;
            //     CheckCameraState();
            // }
        }

        private static void CheckCameraState()
        {
            Debug.Log("CheckCameraState " + k_LockBit);
            WorldCameraManager.cameraController.SetCameraLockStatus(k_LockBit == 0);
            // CameraManager.cameraController.DragEnable = k_LockBit == 0;
            // CameraManager.cameraController.ZoomEnable = k_LockBit == 0;
        }
    }
}